# 这是一个关于蚕自我生存的程序
import random
import time

# 记录蚕的生活
def pupa_life(pupa_name,pupa_food_f,pupa_water_w):
    pupa_name=pupa
    pupa_food_f=pupa_food
    pupa_water_w=pupa_water
    while True:
        for i in range(len(pupa)):
            if pupa_food_f[i]==0 or pupa_water_w[i]==0:
                break
            elif random.randint(0,2)==0:
                pupa_food_f[i]+=1
            elif random.randint(0,2)==1:
                pupa_water_w[i]+=1
            else:
                pupa_food_f[i]-=1
                pupa_water_w[i]-=1
        time.sleep(5)
        # 打印每回合蚕的属性
        print('实验体名称:{}'.format(pupa_name[i]),end='\t')
        print('食物量:{:d}'.format(pupa_food_f[i]),end='\t')
        print('水含量:{:d}'.format(pupa_water_w[i]))


    


# 主函数，用于添加蚕的属性
    # 起始时间
star=time.time()
pupa=[]
pupa_food=[]
pupa_water=[]
#     添加10只蚕
for i in range(1):
    pupa.append(str(i)+'号实验题')
    pupa_food.append(random.randint(1,10))
    pupa_water.append(random.randint(1,10))
print(pupa,pupa_food,pupa_water)
pupa_life(pupa,pupa_food,pupa_water)

        


    
# 结束时间
end=time.time()
print('实验题共生存了{:.2f}秒'.format(end-star))